﻿CREATE VIEW [dbo].[ETL_V_Task]
	AS SELECT
		T.*,
		(SELECT Max(CreatedTime) FROM ETL_TaskExecuteRecord WHERE TaskId = T.Id) as LastExecutedTime,
		DSO.Name as DtSourceName,
		DS.Name as DtSerName,
		(select DT.Name from ETL_DtTable as DT where DT.Id = DSM.DtTableId) as DtTableName
	FROM ETL_Task as T
		left join ETL_DtSource as DSO on DSO.Id = T.DtSourceId
		left join ETL_DtSer as DS on DS.Id = T.DtSerId
		left join ETL_DtSourceMapping DSM on DSM.DtSourceId = T.DtSourceId